package org.example.novel.utlis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;

@SuppressWarnings("all")
@Component
public class RedisUtils {

    @Autowired
    RedisTemplate redisTemplate;

    public void setStr(String key, Object value){
        redisTemplate.opsForValue().set(key,value);
    }

    public void setStr(String key, Object value,long l,TimeUnit timeout){
        redisTemplate.opsForValue().set(key,value,l,timeout);
    }

    public <T> T getStr(String key,Class<T> tClass){
        return (T) redisTemplate.opsForValue().get(key);
    }

    public Object getStr(String key){
        return redisTemplate.opsForValue().get(key);
    }


}
